/*
 *
 *      Copyright (c) ,  All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the  developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author:  ()
 *
 */
package io.dbw.modules.job.controller;

import io.dbw.common.utils.PageUtils;
import io.dbw.common.utils.Result;
import io.dbw.modules.business.controller.sys.AbstractController;
import io.dbw.modules.job.entity.ScheduleJobEntity;
import io.dbw.modules.job.entity.ScheduleJobLogEntity;
import io.dbw.modules.job.service.ScheduleJobLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 定时任务日志
 *
 * @author
 */
@RestController
@RequestMapping("/sys/scheduleLog")
public class ScheduleJobLogController extends AbstractController {
    @Autowired
    private ScheduleJobLogService scheduleJobLogService;

    /**
     * 分页查询定时任务日志
     *
     * @param params 查询参数
     * @return RestResponse
     */
    @GetMapping("/list")
    //@RequiresPermissions("sys:schedule:log")
    public Result<ScheduleJobEntity> list(@RequestParam Map<String, Object> params) {
        PageUtils page = scheduleJobLogService.queryPage(params);

        return writeSuccess(page);
    }

    /**
     * 根据主键查询详情
     *
     * @param logId logId
     * @return RestResponse
     */
    @GetMapping("/info/{logId}")
    public Result info(@PathVariable("logId") String logId) {
        ScheduleJobLogEntity log = scheduleJobLogService.getById(logId);

        return writeSuccess(log);
    }
}
